1. Field of the Invention
The present invention relates to a method and an apparatus for image processing; in particular, the invention relates to a method and apparatus for contrast stretching of image.
2. Description of the Prior Art
Contrast stretching of image is referred as the expansion of the range of the gray scales of an image to the maximum range containable by a display. Using a display capable of showing an 8-bit gray scale as an example, the 256 gray scales of the display are usually expressed as gray scale 0 to gray scale 255. Generally speaking, due to factors like attenuation of signals and interference from noisy signals in received image signals, parts of the gray scales can be lost, and the actual gray scales of the image signals received by the display are usually less than 256. The purpose of image contrast stretching is to increase the range of distribution of image gray scales, by which to enhance image contrast for improving image qualities.
Referring to FIG. 1, FIG. 1 is a flowchart showing the contrast stretching technology of image according to prior art. First, step S11 uses a statistical approach to analyze the distribution of the gray scales of an image. Result of the analysis can be drawn into a histogram showing image properties, as shown in FIGS. 2A˜2C. FIGS. 2A˜2C are examples of histograms of red, green, and blue pixels in the same image to show the image properties. The horizontal axes in FIGS. 2A˜2C represent the gray scale value, whereas the vertical axes represent the number of pixels; the distribution of the gray scales of an image can be understood through the histogram. FIG. 2A through FIG. 2C are respectively drawn to show the respective distribution of the gray scales of the red, the green, and the blue pixels in the same image.
Step S12 searches, in accordance with the histogram described above, for the maximum gray scale value and the minimum gray scale value to be used in the image contrast stretching arithmetic. Some current image processing methods defines the maximum gray scale value as the gray scale value corresponding to 0.5% of the area starting from the right side of the image property histogram, and the minimum gray scale value is defined as the gray scale value corresponding to 0.5% of the area starting from the left side of the image property histogram. Because colored images include red, green, and blue pixels in the images, the previously described maximum gray scale value, for colored images, is the highest maximum gray scale value among the maximum gray scale values of red, green, and blue pixels. Similarly, the minimum gray scale value of the colored image is the lowest minimum gray scale value selected from the minimum gray scale values of red, green, and blue pixels.
Step S13 searches, in accordance with the step S12, for the maximum gray scale value and the minimum gray scale value to perform an image contrast stretching arithmetic. Traditional formula for contrast stretching can be expressed in the following:
                              G          ″                =                  255          ×                                    G              -              Min                                      Max              -              Min                                                          (        1        )            
wherein G represents the original gray scale value, G″ represents the gray scale value after stretching, Max represents the maximum gray scale value, and Min represents the minimum gray scale value.
Formula (1) can be rewritten into another expression:G″=k×(G−Min)  (2)
                    wherein        ,                  k          =                      255                          Max              -              Min                                      ,                            (        3        )            
and k from formula (3) can be referred to as a contrast stretching coefficient or a contrast gain.
Using the image shown in FIG. 3A as an example, the original maximum gray scale value of the image is equal to 151, and the minimum gray scale value is equal to 0. The value k can be calculated using formula 3 to get 1.59, and the result of contrast stretching is shown in FIG. 3B. In comparison, the contrast of FIG. 3B is found to be substantially higher than that of FIG. 3A.
Generally speaking, the purpose of image contrast stretching is to improve the image quality. However, noisy signals in image signals are also proportionally amplified if using the contrast stretching technology of image that is in accordance with prior art. As for image signals, the signal intensity of lower gray scale signals are relatively weaker compared to higher gray scale signals and are more likely to be affected by noisy signals. Sometimes, the amplified noisy signals cause the poor image quality after contrast stretching, thus leading to adverse effects.